//
//  SettingViewController.m
//  EasyChat
//
//  Created by romana on 16/6/16.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "SettingViewController.h"
#import "LoginViewController.h"
#import "SettingCellView.h"



@interface SettingViewController ()



@end

@implementation SettingViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"设置";
    
    [[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
    //修改导航栏标题的颜色 和 大小
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSFontAttributeName:[UIFont systemFontOfSize:19],
                                                                      
                                                                      NSForegroundColorAttributeName:[UIColor whiteColor]}];
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    SettingCellView *view1 = [[SettingCellView alloc] initWithFrame:CGRectMake(0, 64, WIDTH, 50)];
    view1.textLabel.text = @"个人信息";
    [self.view addSubview:view1];
    
    SettingCellView *view2 = [[SettingCellView alloc] initWithFrame:CGRectMake(0, 114, WIDTH, 50)];
    view2.textLabel.text = @"版本信息";
    [self.view addSubview:view2];
    
    SettingCellView *view3 = [[SettingCellView alloc] initWithFrame:CGRectMake(0, 164, WIDTH, 50)];
    view3.textLabel.text = @"黑名单";
    [self.view addSubview:view3];
    
    self.quitButton = [UIButton buttonWithType:UIButtonTypeCustom];
    self.quitButton.backgroundColor = [UIColor colorWithRed:231 / 255.0 green:67 / 255.0 blue:37 / 255.0 alpha:1.0];
    self.quitButton.frame = CGRectMake(10, 230, WIDTH - 20, 50);
        [self.view addSubview:self.quitButton];

   //当前登录的用户名
  NSString *loggingUsername = [[EaseMob sharedInstance].chatManager loginInfo][@"username"];
    
    NSString *title = [NSString stringWithFormat:@"退出登录(%@)",loggingUsername];
    
    [self.quitButton setTitle:title forState:UIControlStateNormal];
    [self.quitButton addTarget:self action:@selector(buttonAction) forControlEvents:UIControlEventTouchUpInside];
    
    // Do any additional setup after loading the view.
}

-(void)buttonAction{

    //ogoffWithUnbindDeviceToken：是否解除 device token 的绑定，在被动退出时传 NO，在主动退出时传 YES。
    EMError *error = nil;
    NSDictionary *info = [[EaseMob sharedInstance].chatManager logoffWithUnbindDeviceToken:YES error:&error];
    if (!error && info) {
        NSLog(@"退出成功");
    }
    //并跳转回登录界面
    LoginViewController *LoginVC = [LoginViewController new];
    [self presentViewController:LoginVC animated:YES completion:^{
        
        
    }];


}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
